//
//  personSettingViewController.m
//  FastRunDemo
//
//  Created by 苟亚明 on 16/9/22.
//  Copyright © 2016年 苟亚明. All rights reserved.
//

#import "personSettingViewController.h"
#import "personSetting.h"
#import "personSettingCell.h"
#import "XCFeedBackViewController.h"
#import "aboutFastRunViewController.h"
#import "askCustomerServiceViewController.h"
@interface personSettingViewController () <UITableViewDataSource,UITableViewDelegate>
@property (strong, nonatomic) UITableView *tableView;
@property (nonatomic, strong) NSArray *arrayTitle;
@property (nonatomic, strong) NSArray *arrayIcon;

@end

@implementation personSettingViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    UIImage *image = [UIImage imageNamed:@"transparent-1"];
    [self.navigationController.navigationBar setBackgroundImage:image
                                                  forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:image];

}
static NSString *const personSettingCellId = @"personSettingCell.h";
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"设置";
    self.arrayTitle = @[@"修改密码",
                        @"意见反馈",
                        @"系统通知",
                        @"客服中心",
                        @"关于快跑"];
    self.arrayIcon = @[@"person_setting_lock",
                       @"person_setting_feedBack",
                       @"person_setting_notice",
                       @"person_setting_ service",
                       @"person_setting_about"];
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"arrow_back" highImage:@"arrow_back" target:self action:@selector(leftBtnClick)];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, GYMScreenW, GYMScreenH )];
    personSetting *header = [[[NSBundle mainBundle]loadNibNamed:@"personSetting" owner:nil options:nil]lastObject];
    header.frame = CGRectMake(0, 0, GYMScreenW, 180);
    self.tableView.tableHeaderView = header;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView registerNib:[UINib nibWithNibName:@"personSettingCell" bundle:nil] forCellReuseIdentifier:personSettingCellId];
    
    [self.view addSubview:self.tableView];
}

- (void)leftBtnClick{
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arrayTitle.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    personSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:personSettingCellId];
    cell.lblTitle.text = self.arrayTitle[indexPath.row];
    cell.imgIcon.image = [UIImage imageNamed:self.arrayIcon[indexPath.row]];
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 1) {
        XCFeedBackViewController *vc = [[XCFeedBackViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    } else if (indexPath.row == 4){
        aboutFastRunViewController *vc = [[aboutFastRunViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 3){
        askCustomerServiceViewController *vc = [[askCustomerServiceViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

@end
